diff --git a/src/libs/tgf/application.cpp b/src/libs/tgf/application.cpp index 945b41cb..73f69c2d 100644 --- a/src/libs/tgf/application.cpp +++ b/src/libs/tgf/application.cpp @@ -128,20 +128,33 @@ GfEventLoop& GfApplication::eventLoop() return *_pEventLoop; } +void GfApplication::restart() +{ + // Shutdown the gaming framework. + GfShutdown(); + + // Delete the event loop if any. + delete _pEventLoop; + + // Restart. + GfRestart(); +} + void GfApplication::exit(int nStatusCode) { + // Shutdown the gaming framework. + GfShutdown(); + + // Delete the event loop if any. + delete _pEventLoop; + + // Trace what we are doing. if (!nStatusCode) GfLogInfo("Exiting normally from %s.\n", _strName.c_str()); else std::cerr << "Exiting from " << _strName << " after some error occurred (see above)." << std::endl; - // Shutdown the gaming framework. - GfShutdown(); - - // Delete the event loop if any. - delete _pEventLoop; - // The end. ::exit(nStatusCode); } diff --git a/src/libs/tgf/tgf.hpp b/src/libs/tgf/tgf.hpp index 99dc7044..933979d5 100644 --- a/src/libs/tgf/tgf.hpp +++ b/src/libs/tgf/tgf.hpp @@ -176,6 +176,9 @@ class TGF_API GfApplication void setEventLoop(GfEventLoop* pEventLoop); GfEventLoop& eventLoop(); + //! Restart the app. + virtual void restart(); + //! Exit from the app. virtual void exit(int nStatusCode = 0); diff --git a/src/libs/tgfclient/guiapplication.cpp b/src/libs/tgfclient/guiapplication.cpp index d34aaa04..14012a7a 100644 --- a/src/libs/tgfclient/guiapplication.cpp +++ b/src/libs/tgfclient/guiapplication.cpp @@ -59,6 +59,7 @@ bool GfuiApplication::parseOptions() bool GfuiApplication::setupWindow(bool bNoMenu) { // Initialize the window/screen. + _bWindowUp = true; // In case, GfScrInit() would call restart() ... _bWindowUp = GfScrInit(); // Initialize the UI menu infrastructure. @@ -79,6 +80,25 @@ GfuiEventLoop& GfuiApplication::eventLoop() return *dynamic_cast(_pEventLoop); } +void GfuiApplication::restart() +{ + // Shutdown the window/screen. + if (_bWindowUp) + { + GfScrShutdown(); + _bWindowUp = false; + } + + // Shutdown the gaming framework. + GfShutdown(); + + // Delete the event loop if any. + delete _pEventLoop; + + // Restart. + GfRestart(GfuiMouseIsHWPresent()); +} + void GfuiApplication::exit(int nStatusCode) { // Shutdown the window/screen. diff --git a/src/libs/tgfclient/tgfclient.h b/src/libs/tgfclient/tgfclient.h index 6e96b872..125c5fe2 100644 --- a/src/libs/tgfclient/tgfclient.h +++ b/src/libs/tgfclient/tgfclient.h @@ -81,6 +81,7 @@ typedef struct ScreenSize TGFCLIENT_API bool GfScrInit(void); TGFCLIENT_API void GfScrShutdown(void); TGFCLIENT_API void GfScrGetSize(int *scrW, int *scrH, int *viewW, int *viewH); +TGFCLIENT_API bool GfScrToggleFullScreen(); TGFCLIENT_API unsigned char* GfScrCaptureAsImage(int* viewW, int *viewH); TGFCLIENT_API int GfScrCaptureAsPNG(const char *filename); @@ -640,6 +641,9 @@ class TGFCLIENT_API GfuiApplication : public GfApplication //! Application event loop. GfuiEventLoop& eventLoop(); + //! Restart the app. + virtual void restart(); + //! Exit from the app. virtual void exit(int nStatusCode = 0);