equal
deleted
inserted
replaced
82 |
82 |
83 QStringList SDLInteraction::getResolutions() const |
83 QStringList SDLInteraction::getResolutions() const |
84 { |
84 { |
85 QStringList result; |
85 QStringList result; |
86 |
86 |
|
87 #if SDL_VERSION_ATLEAST(2, 0, 0) |
|
88 int modesNumber = SDL_GetNumDisplayModes(0); |
|
89 SDL_DisplayMode mode; |
|
90 |
|
91 for(int i = 0; i < modesNumber; ++i) |
|
92 { |
|
93 SDL_GetDisplayMode(0, i, &mode); |
|
94 |
|
95 if ((mode.w >= 640) && (mode.h >= 480)) |
|
96 result << QString("%1x%2").arg(mode.w).arg(mode.h); |
|
97 } |
|
98 #else |
87 SDL_Rect **modes; |
99 SDL_Rect **modes; |
88 |
100 |
89 modes = SDL_ListModes(NULL, SDL_FULLSCREEN); |
101 modes = SDL_ListModes(NULL, SDL_FULLSCREEN); |
90 |
102 |
91 if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) |
103 if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) |
96 { |
108 { |
97 for(int i = 0; modes[i]; ++i) |
109 for(int i = 0; modes[i]; ++i) |
98 if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) |
110 if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) |
99 result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); |
111 result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); |
100 } |
112 } |
|
113 #endif |
101 |
114 |
102 return result; |
115 return result; |
103 } |
116 } |
104 |
117 |
105 |
118 |
106 void SDLInteraction::addGameControllerKeys() const |
119 void SDLInteraction::addGameControllerKeys() const |
107 { |
120 { |
108 QStringList result; |
121 QStringList result; |
109 |
122 |
|
123 #if SDL_VERSION_ATLEAST(2, 0, 0) |
|
124 |
|
125 #else |
110 int i = 0; |
126 int i = 0; |
111 while(i < 1024 && sdlkeys[i][1][0] != '\0') |
127 while(i < 1024 && sdlkeys[i][1][0] != '\0') |
112 i++; |
128 i++; |
113 |
129 |
114 // Iterate through all game controllers |
130 // Iterate through all game controllers |
175 SDL_JoystickClose(joy); |
191 SDL_JoystickClose(joy); |
176 } |
192 } |
177 |
193 |
178 // Terminate the list |
194 // Terminate the list |
179 sdlkeys[i][0][0] = '\0'; |
195 sdlkeys[i][0][0] = '\0'; |
180 sdlkeys[i][1][0] = '\0'; |
196 sdlkeys[i][1][0] = '\0'; |
|
197 #endif |
181 } |
198 } |
182 |
199 |
183 |
200 |
184 void SDLInteraction::SDLAudioInit() |
201 void SDLInteraction::SDLAudioInit() |
185 { |
202 { |
237 |
254 |
238 SDLAudioInit(); |
255 SDLAudioInit(); |
239 if (!m_audioInitialized) return; |
256 if (!m_audioInitialized) return; |
240 |
257 |
241 if (m_music == NULL) |
258 if (m_music == NULL) |
242 m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData())); |
259 m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()), 0); |
243 |
260 |
244 Mix_VolumeMusic(MIX_MAX_VOLUME - 28); |
261 Mix_VolumeMusic(MIX_MAX_VOLUME - 28); |
245 Mix_FadeInMusic(m_music, -1, 1750); |
262 Mix_FadeInMusic(m_music, -1, 1750); |
246 } |
263 } |
247 |
264 |
258 } |
275 } |
259 |
276 |
260 m_isPlayingMusic = false; |
277 m_isPlayingMusic = false; |
261 } |
278 } |
262 |
279 |
|
280 |
|
281 QSize SDLInteraction::getCurrentResolution() |
|
282 { |
|
283 #if SDL_VERSION_ATLEAST(2, 0, 0) |
|
284 SDL_DisplayMode mode; |
|
285 |
|
286 SDL_GetDesktopDisplayMode(0, &mode); |
|
287 |
|
288 return QSize(mode.w, mode.h); |
|
289 #else |
|
290 SDL_VideoInfo * vi = SDL_GetVideoInfo(); |
|
291 return QSize(vi->current_w, vi->current_h); |
|
292 #endif |
|
293 } |