mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Interface added: CMusicHandler::playLodSnd(std::string name).
We can play wav data of Heroes3.snd through CMusicHandler::playLodSnd(std::string name) now, where name can be "BASLDFND.wav" or "BASLKILL.wav".
This commit is contained in:
parent
9c4cb94490
commit
3a279a7964
@ -56,7 +56,7 @@ void CMusicHandler::initMusics()
|
|||||||
click = Mix_LoadWAV("MP3\\snd1.wav");
|
click = Mix_LoadWAV("MP3\\snd1.wav");
|
||||||
click->volume = 30;
|
click->volume = 30;
|
||||||
|
|
||||||
this->sndPlayer = new CSndPlayer();
|
this->sndh = new CSndHandler(std::string("Data\\Heroes3.snd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMusicHandler::playClick()
|
void CMusicHandler::playClick()
|
||||||
@ -69,7 +69,25 @@ void CMusicHandler::playClick()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMusicHandler::playLodSnd(std::string sndname)
|
void CMusicHandler::playLodSnd(std::string sndname)
|
||||||
{
|
{
|
||||||
return this->sndPlayer->playLodSnd(sndname);
|
int size;
|
||||||
|
unsigned char *data;
|
||||||
|
SDL_RWops *ops;
|
||||||
|
Mix_Chunk *chunk;
|
||||||
|
int channel;
|
||||||
|
|
||||||
|
if ((data = sndh->extract(sndname, size)) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ops = SDL_RWFromConstMem(data, size);
|
||||||
|
chunk = Mix_LoadWAV_RW(ops, 1);
|
||||||
|
|
||||||
|
channel = Mix_PlayChannel(-1, chunk, 0);
|
||||||
|
if(channel == -1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unable to play WAV file(Data\\Heroes3.wav::%s): %s\n",
|
||||||
|
sndname.c_str(),Mix_GetError());
|
||||||
|
}
|
||||||
|
ops->close(ops);
|
||||||
}
|
}
|
@ -2,18 +2,18 @@
|
|||||||
#define CMUSICHANDLER_H
|
#define CMUSICHANDLER_H
|
||||||
|
|
||||||
#include "SDL_mixer.h"
|
#include "SDL_mixer.h"
|
||||||
#include "CSndPlayer.h"
|
#include "CSndHandler.h"
|
||||||
|
|
||||||
class CMusicHandler
|
class CMusicHandler
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CSndPlayer *sndPlayer;
|
CSndHandler *sndh;
|
||||||
public:
|
public:
|
||||||
Mix_Music *AITheme0, *AITheme1, *AITheme2, *combat1, *combat2, *combat3, *combat4, *castleTown, *defendCastle, *dirt, *dungeon, *elemTown, *evilTheme, *fortressTown, *goodTheme, *grass, *infernoTown, *lava, *loopLepr, *loseCampain, *loseCastle, *loseCombat, *mainMenu, *mainMenuWoG, *necroTown, *neutralTheme, *rampart, *retreatBattle, *rough, *sand, *secretTheme, *snow, *stronghold, *surrenderBattle, *swamp, *towerTown, *ultimateLose, *underground, *water, *winScenario, *winBattle;
|
Mix_Music *AITheme0, *AITheme1, *AITheme2, *combat1, *combat2, *combat3, *combat4, *castleTown, *defendCastle, *dirt, *dungeon, *elemTown, *evilTheme, *fortressTown, *goodTheme, *grass, *infernoTown, *lava, *loopLepr, *loseCampain, *loseCastle, *loseCombat, *mainMenu, *mainMenuWoG, *necroTown, *neutralTheme, *rampart, *retreatBattle, *rough, *sand, *secretTheme, *snow, *stronghold, *surrenderBattle, *swamp, *towerTown, *ultimateLose, *underground, *water, *winScenario, *winBattle;
|
||||||
Mix_Chunk * buildTown, *click;
|
Mix_Chunk * buildTown, *click;
|
||||||
void initMusics();
|
void initMusics();
|
||||||
void playClick(); //plays click music ;]
|
void playClick(); //plays click music ;]
|
||||||
bool playLodSnd(std::string sndname); // plays sound wavs from Heroes3.snd
|
void playLodSnd(std::string sndname); // plays sound wavs from Heroes3.snd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user