# HG changeset patch # User unc0rr # Date 1384114520 -14400 # Node ID 7f67866256670d76e70a889b703b4666f86bd886 # Parent fab319c85a39370f7cd0cca28ee9b1f72b36eeef Frontend builds diff -r fab319c85a39 -r 7f6786625667 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Sun Nov 10 14:04:15 2013 +0400 +++ b/QTfrontend/CMakeLists.txt Mon Nov 11 00:15:20 2013 +0400 @@ -205,10 +205,20 @@ list(APPEND HW_LINK_LIBS physfs physlayer ${QT_LIBRARIES} - ${SDL_LIBRARY} - ${SDLMIXER_LIBRARY} ) +if(USESDL12) + list(APPEND HW_LINK_LIBS + ${SDL_LIBRARY} + ${SDLMIXER_LIBRARY} + ) +else() + list(APPEND HW_LINK_LIBS + ${SDL2_LIBRARY} + ${SDL2MIXER_LIBRARY} + ) +endif() + if(WIN32 AND NOT UNIX) if(NOT SDL_LIBRARY) list(APPEND HW_LINK_LIBS SDL) diff -r fab319c85a39 -r 7f6786625667 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sun Nov 10 14:04:15 2013 +0400 +++ b/QTfrontend/gameuiconfig.cpp Mon Nov 11 00:15:20 2013 +0400 @@ -86,10 +86,11 @@ else Form->ui.pageOptions->CBResolution->setCurrentIndex(t); // Default the windowed resolution to 5/6 of the screen size - int screenWidth = SDL_GetVideoInfo()->current_w * 5 / 6; - int screenHeight = SDL_GetVideoInfo()->current_h * 5 / 6; - QString widthStr; widthStr.setNum(screenWidth); - QString heightStr; heightStr.setNum(screenHeight); + QSize screenSize = SDLInteraction::instance().getCurrentResolution(); + screenSize *= 5.0 / 6; + + QString widthStr = QString::number(screenSize.width()); + QString heightStr = QString::number(screenSize.height()); QString wWidth = value("video/windowedWidth", widthStr).toString(); QString wHeight = value("video/windowedHeight", heightStr).toString(); // If left blank reset the resolution to the default diff -r fab319c85a39 -r 7f6786625667 QTfrontend/util/SDLInteraction.cpp --- a/QTfrontend/util/SDLInteraction.cpp Sun Nov 10 14:04:15 2013 +0400 +++ b/QTfrontend/util/SDLInteraction.cpp Mon Nov 11 00:15:20 2013 +0400 @@ -84,6 +84,18 @@ { QStringList result; +#if SDL_VERSION_ATLEAST(2, 0, 0) + int modesNumber = SDL_GetNumDisplayModes(0); + SDL_DisplayMode mode; + + for(int i = 0; i < modesNumber; ++i) + { + SDL_GetDisplayMode(0, i, &mode); + + if ((mode.w >= 640) && (mode.h >= 480)) + result << QString("%1x%2").arg(mode.w).arg(mode.h); + } +#else SDL_Rect **modes; modes = SDL_ListModes(NULL, SDL_FULLSCREEN); @@ -98,6 +110,7 @@ if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); } +#endif return result; } @@ -107,6 +120,9 @@ { QStringList result; +#if SDL_VERSION_ATLEAST(2, 0, 0) + +#else int i = 0; while(i < 1024 && sdlkeys[i][1][0] != '\0') i++; @@ -177,7 +193,8 @@ // Terminate the list sdlkeys[i][0][0] = '\0'; - sdlkeys[i][1][0] = '\0'; + sdlkeys[i][1][0] = '\0'; +#endif } @@ -239,7 +256,7 @@ if (!m_audioInitialized) return; if (m_music == NULL) - m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData())); + m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()), 0); Mix_VolumeMusic(MIX_MAX_VOLUME - 28); Mix_FadeInMusic(m_music, -1, 1750); @@ -260,3 +277,17 @@ m_isPlayingMusic = false; } + +QSize SDLInteraction::getCurrentResolution() +{ +#if SDL_VERSION_ATLEAST(2, 0, 0) + SDL_DisplayMode mode; + + SDL_GetDesktopDisplayMode(0, &mode); + + return QSize(mode.w, mode.h); +#else + SDL_VideoInfo * vi = SDL_GetVideoInfo(); + return QSize(vi->current_w, vi->current_h); +#endif +} diff -r fab319c85a39 -r 7f6786625667 QTfrontend/util/SDLInteraction.h --- a/QTfrontend/util/SDLInteraction.h Sun Nov 10 14:04:15 2013 +0400 +++ b/QTfrontend/util/SDLInteraction.h Mon Nov 11 00:15:20 2013 +0400 @@ -27,6 +27,7 @@ #include #include +#include #include "SDL_mixer.h" @@ -103,6 +104,8 @@ /// Fades out and stops the background music (if playing). void stopMusic(); + + QSize getCurrentResolution(); }; diff -r fab319c85a39 -r 7f6786625667 project_files/hedgewars.pro --- a/project_files/hedgewars.pro Sun Nov 10 14:04:15 2013 +0400 +++ b/project_files/hedgewars.pro Mon Nov 11 00:15:20 2013 +0400 @@ -273,8 +273,8 @@ } !macx { - LIBS += -lSDL -lSDL_mixer -lSDL_net + LIBS += -lSDL2 -lSDL2_mixer -lSDL2_net !win32 { - INCLUDEPATH += /usr/local/include/SDL /usr/include/SDL + INCLUDEPATH += /usr/local/include/SDL2 /usr/include/SDL2 } }