diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-21 21:18:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-24 21:08:15 +0300 |
commit | a3082da9c7296bb18b7a6bc0424eb2a19d485ff6 (patch) | |
tree | cd07d091f69f5a3000aaddcbc8911d472b9137e7 /src/client.cpp | |
parent | 84189722a64c0794fbd918b4e6412908be2b7394 (diff) | |
download | manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.gz manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.bz2 manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.tar.xz manaverse-a3082da9c7296bb18b7a6bc0424eb2a19d485ff6.zip |
second part with compilation fixes for SDL2.
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 80 |
1 files changed, 68 insertions, 12 deletions
diff --git a/src/client.cpp b/src/client.cpp index 38fc440f9..29d81ad64 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -483,7 +483,11 @@ void Client::gameInit() SMALL_VERSION); } +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowTitle +#else SDL_WM_SetCaption(mCaption.c_str(), nullptr); +#endif const ResourceManager *const resman = ResourceManager::getInstance(); @@ -589,7 +593,11 @@ void Client::gameInit() #else SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); #endif +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowIcon +#else SDL_WM_SetIcon(mIcon, nullptr); +#endif } #endif @@ -1026,9 +1034,26 @@ int Client::gameExec() // logger->log("unknown event: %d", event.type); break; +#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; + } + break; + } +#else case SDL_VIDEORESIZE: resizeVideo(event.resize.w, event.resize.h, false); break; +#endif } guiInput->pushInput(event); @@ -1076,6 +1101,9 @@ int Client::gameExec() // This is done because at some point tick_time will wrap. lastTickTime = tick_time; +#ifdef USE_SDL2 + mainGraphics->updateScreen(); +#else // Update the screen when application is active, delay otherwise. if (SDL_GetAppState() & SDL_APPACTIVE) { @@ -1083,13 +1111,12 @@ int Client::gameExec() if (gui) gui->draw(); mainGraphics->updateScreen(); -// logger->log("active"); } else { -// logger->log("inactive"); SDL_Delay(100); } +#endif BLOCK_START("~Client::SDL_framerateDelay") if (mLimitFps) @@ -2865,8 +2892,12 @@ void Client::resizeVideo(int width, int height, const bool always) void Client::applyGrabMode() { +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowGrab +#else SDL_WM_GrabInput(config.getBoolValue("grabinput") ? SDL_GRAB_ON : SDL_GRAB_OFF); +#endif } void Client::applyGamma() @@ -2874,15 +2905,21 @@ void Client::applyGamma() if (config.getFloatValue("enableGamma")) { const float val = config.getFloatValue("gamma"); +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowBrightness +#else SDL_SetGamma(val, val, val); +#endif } } void Client::applyVSync() { +#ifndef USE_SDL2 const int val = config.getIntValue("vsync"); if (val > 0 && val < 2) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val); +#endif } void Client::applyKeyRepeat() @@ -2903,7 +2940,11 @@ void Client::setIsMinimized(const bool n) if (!n && client->mNewMessageFlag) { client->mNewMessageFlag = false; +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowTitle +#else SDL_WM_SetCaption(client->mCaption.c_str(), nullptr); +#endif } } @@ -2916,7 +2957,11 @@ void Client::newChatMessage() if (!client->mNewMessageFlag && client->mIsMinimized) { // show * on window caption +#ifdef USE_SDL2 + // +++ need use SDL_SetWindowTitle +#else SDL_WM_SetCaption(("*" + client->mCaption).c_str(), nullptr); +#endif client->mNewMessageFlag = true; } } @@ -2938,6 +2983,16 @@ void Client::logEvent(const SDL_Event &event) logger->log("event: SDL_MOUSEMOTION: %d,%d,%d", event.motion.state, event.motion.x, event.motion.y); break; +#ifdef USE_SDL2 + case SDL_KEYDOWN: + logger->log("event: SDL_KEYDOWN: %d,%d", event.key.state, + event.key.keysym.scancode); + break; + case SDL_KEYUP: + logger->log("event: SDL_KEYUP: %d,%d", event.key.state, + event.key.keysym.scancode); + break; +#else case SDL_KEYDOWN: logger->log("event: SDL_KEYDOWN: %d,%d,%d", event.key.state, event.key.keysym.scancode, event.key.keysym.unicode); @@ -2946,6 +3001,17 @@ void Client::logEvent(const SDL_Event &event) logger->log("event: SDL_KEYUP: %d,%d,%d", event.key.state, event.key.keysym.scancode, event.key.keysym.unicode); break; + case SDL_VIDEORESIZE: + logger->log("event: SDL_VIDEORESIZE"); + break; + case SDL_VIDEOEXPOSE: + logger->log("event: SDL_VIDEOEXPOSE"); + break; + case SDL_ACTIVEEVENT: + logger->log("event: SDL_ACTIVEEVENT: %d %d", + event.active.state, event.active.gain); + break; +#endif case SDL_MOUSEBUTTONDOWN: logger->log("event: SDL_MOUSEBUTTONDOWN: %d,%d,%d,%d", event.button.button, event.button.state, @@ -2985,19 +3051,9 @@ void Client::logEvent(const SDL_Event &event) case SDL_SYSWMEVENT: logger->log("event: SDL_SYSWMEVENT"); break; - case SDL_VIDEORESIZE: - logger->log("event: SDL_VIDEORESIZE"); - break; - case SDL_VIDEOEXPOSE: - logger->log("event: SDL_VIDEOEXPOSE"); - break; case SDL_USEREVENT: logger->log("event: SDL_USEREVENT"); break; - case SDL_ACTIVEEVENT: - logger->log("event: SDL_ACTIVEEVENT: %d %d", - event.active.state, event.active.gain); - break; #ifdef ANDROID case SDL_ACCELEROMETER: logger->log("event: SDL_ACCELEROMETER"); |