diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 27 | ||||
-rw-r--r-- | src/client.h | 6 | ||||
-rw-r--r-- | src/game.cpp | 11 | ||||
-rw-r--r-- | src/main.cpp | 14 |
4 files changed, 33 insertions, 25 deletions
diff --git a/src/client.cpp b/src/client.cpp index 2d1a2d82b..6cb9ac028 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -155,6 +155,7 @@ Configuration serverConfig; // XML file server configuration reader Configuration features; // XML file features Configuration branding; // XML branding information reader Configuration paths; // XML default paths information reader +Client *client = nullptr; Logger *logger = nullptr; // Log object ChatLogger *chatLogger = nullptr; // Chat log object KeyboardConfig keyboard; @@ -1000,16 +1001,7 @@ int Client::gameExec() #ifdef USE_SDL2 case SDL_WINDOWEVENT: { - switch (event.window.event) - { - // +++ need add other window events - case SDL_WINDOWEVENT_RESIZED: - resizeVideo(event.window.data1, - event.window.data2, false); - break; - default: - break; - } + handleSDL2WindowEvent(event); break; } #else @@ -3165,3 +3157,18 @@ void Client::setIcon() } #endif } + +#ifdef USE_SDL2 +void Client::handleSDL2WindowEvent(const SDL_Event &event) +{ + switch (event.window.event) + { + // +++ need add other window events + case SDL_WINDOWEVENT_RESIZED: + resizeVideo(event.window.data1, event.window.data2, false); + break; + default: + break; + } +} +#endif diff --git a/src/client.h b/src/client.h index 938170610..a4d7a288c 100644 --- a/src/client.h +++ b/src/client.h @@ -317,6 +317,10 @@ public: static void applyKeyRepeat(); +#ifdef USE_SDL2 + void handleSDL2WindowEvent(const SDL_Event &event); +#endif + void optionChanged(const std::string &name) override; void action(const gcn::ActionEvent &event) override; @@ -443,4 +447,6 @@ private: bool mLogInput; }; +extern Client *client; + #endif // CLIENT_H diff --git a/src/game.cpp b/src/game.cpp index f4dc97ed6..80408f836 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -972,16 +972,7 @@ void Game::handleInput() #ifdef USE_SDL2 case SDL_WINDOWEVENT: { - switch (event.window.event) - { - // +++ need add other window events - case SDL_WINDOWEVENT_RESIZED: - Client::resize(event.window.data1, - event.window.data2, false); - break; - default: - break; - } + client->handleSDL2WindowEvent(event); break; } #else diff --git a/src/main.cpp b/src/main.cpp index 7bedd1b9d..f367d80fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -308,17 +308,21 @@ int main(int argc, char *argv[]) SetCurrentDirectory(PhysFs::getBaseDir()); #endif setPriority(true); - Client client(options); + client = new Client(options); + int ret = 0; if (!options.testMode) { - client.gameInit(); - return client.gameExec(); + client->gameInit(); + ret = client->gameExec(); } else { - client.testsInit(); - return client.testsExec(); + client->testsInit(); + ret = client->testsExec(); } + delete client; + client = nullptr; + return ret; } #else |