QTfrontend/util/SDLInteraction.cpp
branchsdl2transition
changeset 11362 ed5a6478e710
parent 11360 7a7611adf715
parent 11046 47a8c19ecb60
child 13514 31d0b0911cba
equal deleted inserted replaced
11361:31570b766315 11362:ed5a6478e710
     1 /*
     1 /*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    12  * GNU General Public License for more details.
    13  *
    13  *
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    17  */
    17  */
    18 
    18 
    19 /**
    19 /**
    20  * @file
    20  * @file
    21  * @brief SDLInteraction class implementation
    21  * @brief SDLInteraction class implementation
    52 
    52 
    53     m_audioInitialized = false;
    53     m_audioInitialized = false;
    54     m_music = NULL;
    54     m_music = NULL;
    55     m_musicTrack = "";
    55     m_musicTrack = "";
    56     m_isPlayingMusic = false;
    56     m_isPlayingMusic = false;
       
    57     lastchannel = 0;
    57     if(SDL_NumJoysticks())
    58     if(SDL_NumJoysticks())
    58         addGameControllerKeys();
    59         addGameControllerKeys();
    59     SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
    60     SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
    60 
    61 
    61     m_soundMap = new QMap<QString,Mix_Chunk*>();
    62     m_soundMap = new QMap<QString,Mix_Chunk*>();
   172         }
   173         }
   173         // Close the game controller as we no longer need it
   174         // Close the game controller as we no longer need it
   174         SDL_JoystickClose(joy);
   175         SDL_JoystickClose(joy);
   175     }
   176     }
   176 
   177 
       
   178     if(i >= 1024)
       
   179         i = 1023;
       
   180 
   177     // Terminate the list
   181     // Terminate the list
   178     sdlkeys[i][0][0] = '\0';
   182     sdlkeys[i][0][0] = '\0';
   179     sdlkeys[i][1][0] = '\0';   
   183     sdlkeys[i][1][0] = '\0';   
   180 #endif
   184 #endif
   181 }
   185 }
   239     if (!m_audioInitialized) return;
   243     if (!m_audioInitialized) return;
   240 
   244 
   241     if (m_music == NULL)
   245     if (m_music == NULL)
   242         m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()), 0);
   246         m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData()), 0);
   243 
   247 
   244     Mix_VolumeMusic(MIX_MAX_VOLUME - 28);
   248     Mix_VolumeMusic(MIX_MAX_VOLUME/4);
   245     Mix_FadeInMusic(m_music, -1, 1750);
   249     Mix_FadeInMusic(m_music, -1, 1750);
   246 }
   250 }
   247 
   251 
   248 
   252 
   249 void SDLInteraction::stopMusic()
   253 void SDLInteraction::stopMusic()