diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-01-25 23:01:59 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-01-25 23:01:59 +0800 |
commit | 841465ea45e56bf2f294b5cb934e5ff955c72401 (patch) | |
tree | 6ea71790c1b1c8458cdf6b2b751788ecd32943bf /smelt/sdl/sys_sdl.cpp | |
parent | 1d64816653b5d1835dd60762c2bc64f000d88fa5 (diff) | |
download | SMELT-841465ea45e56bf2f294b5cb934e5ff955c72401.tar.xz |
Texture options.
Add smHandler* version of event handlers.
Diffstat (limited to 'smelt/sdl/sys_sdl.cpp')
-rw-r--r-- | smelt/sdl/sys_sdl.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/smelt/sdl/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp index 675d88f..427b1bf 100644 --- a/smelt/sdl/sys_sdl.cpp +++ b/smelt/sdl/sys_sdl.cpp @@ -182,8 +182,11 @@ void SMELT_IMPL::smMainLoop() void SMELT_IMPL::smUpdateFunc(smHook func){pUpdateFunc=func;} void SMELT_IMPL::smUpdateFunc(smHandler* h){updateHandler=h;} void SMELT_IMPL::smUnFocFunc(smHook func){pUnFocFunc=func;} +void SMELT_IMPL::smUnFocFunc(smHandler* h){unFocHandler=h;} void SMELT_IMPL::smFocFunc(smHook func){pFocFunc=func;} +void SMELT_IMPL::smFocFunc(smHandler* h){focHandler=h;} void SMELT_IMPL::smQuitFunc(smHook func){pQuitFunc=func;} +void SMELT_IMPL::smQuitFunc(smHandler* h){quitHandler=h;} void SMELT_IMPL::smWinTitle(const char *title){strcpy(winTitle,title);} bool SMELT_IMPL::smIsActive(){return Active;} void SMELT_IMPL::smNoSuspend(bool para){noSuspend=para;} @@ -250,7 +253,8 @@ float SMELT_IMPL::smGetTime(){return timeS;} SMELT_IMPL::SMELT_IMPL() { hwnd=NULL;Active=false;memset(curError,0,sizeof(curError)); - pUpdateFunc=pUnFocFunc=pFocFunc=pQuitFunc=NULL;updateHandler=NULL; + pUpdateFunc=pUnFocFunc=pFocFunc=pQuitFunc=NULL; + updateHandler=unFocHandler=focHandler=quitHandler=NULL; Icon=NULL;strcpy(winTitle,"untitled");scrw=dispw=800;scrh=disph=600; windowed=vsync=false;memset(logFile,0,sizeof(logFile)); limfps=0;hideMouse=true;noSuspend=false; @@ -263,8 +267,8 @@ SMELT_IMPL::SMELT_IMPL() void SMELT_IMPL::focusChange(bool actif) { Active=actif; - if(actif)pFocFunc?pFocFunc():0; - else pUnFocFunc?pUnFocFunc():0; + if(actif){pFocFunc?pFocFunc():0;focHandler?focHandler->handlerFunc():0;} + else {pUnFocFunc?pUnFocFunc():0;unFocHandler?unFocHandler->handlerFunc():0;}; } bool SMELT_IMPL::procSDLEvent(const SDL_Event &e) { @@ -291,8 +295,13 @@ bool SMELT_IMPL::procSDLEvent(const SDL_Event &e) } break; case SDL_QUIT: - if(pSM->pQuitFunc&&!pSM->pQuitFunc())break; - return false; + { + bool accepted=true; + if(pSM->pQuitFunc&&pSM->pQuitFunc())accepted=false; + if(pSM->quitHandler&&quitHandler->handlerFunc())accepted=false; + if(accepted)return false; + } + break; case SDL_KEYDOWN: keymods=(SDL_Keymod)e.key.keysym.mod; if((keymods&KMOD_ALT)&&((e.key.keysym.sym==SDLK_RETURN)||(e.key.keysym.sym==SDLK_KP_ENTER))) |