mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
Play Wav from Lod directly. Need a little more work..
This commit is contained in:
parent
bd7cf60f13
commit
9c4cb94490
@ -55,6 +55,8 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMusicHandler::playClick()
|
void CMusicHandler::playClick()
|
||||||
@ -65,4 +67,9 @@ void CMusicHandler::playClick()
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError());
|
fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMusicHandler::playLodSnd(std::string sndname)
|
||||||
|
{
|
||||||
|
return this->sndPlayer->playLodSnd(sndname);
|
||||||
}
|
}
|
@ -2,14 +2,18 @@
|
|||||||
#define CMUSICHANDLER_H
|
#define CMUSICHANDLER_H
|
||||||
|
|
||||||
#include "SDL_mixer.h"
|
#include "SDL_mixer.h"
|
||||||
|
#include "CSndPlayer.h"
|
||||||
|
|
||||||
class CMusicHandler
|
class CMusicHandler
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
CSndPlayer *sndPlayer;
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
CSndHandler::~CSndHandler()
|
CSndHandler::~CSndHandler()
|
||||||
{
|
{
|
||||||
entries.clear();
|
entries.clear();
|
||||||
|
fimap.clear();
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
||||||
@ -36,6 +37,7 @@ CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
|||||||
entry.offset = readNormalNr(-1,4);
|
entry.offset = readNormalNr(-1,4);
|
||||||
entry.size = readNormalNr(-1,4);
|
entry.size = readNormalNr(-1,4);
|
||||||
entries.push_back(entry);
|
entries.push_back(entry);
|
||||||
|
fimap[entry.name] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int CSndHandler::readNormalNr (int pos, int bytCon)
|
int CSndHandler::readNormalNr (int pos, int bytCon)
|
||||||
@ -124,6 +126,19 @@ unsigned char * CSndHandler::extract (int index, int & size)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char * CSndHandler::extract (std::string srcName, int &size)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
std::map<std::string, int>::iterator fit;
|
||||||
|
if ((fit = fimap.find(srcName)) != fimap.end())
|
||||||
|
{
|
||||||
|
index = fit->second;
|
||||||
|
return this->extract(index, size);
|
||||||
|
}
|
||||||
|
size = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CVidHandler::~CVidHandler()
|
CVidHandler::~CVidHandler()
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
struct MemberFile
|
struct MemberFile
|
||||||
{
|
{
|
||||||
std::ifstream * ifs;
|
std::ifstream * ifs;
|
||||||
@ -22,10 +23,11 @@ protected:
|
|||||||
bool opened;
|
bool opened;
|
||||||
public:
|
public:
|
||||||
std::vector<Entry> entries;
|
std::vector<Entry> entries;
|
||||||
|
std::map<std::string, int> fimap; // map of wav file and index
|
||||||
~CSndHandler();
|
~CSndHandler();
|
||||||
CSndHandler(std::string fname);
|
CSndHandler(std::string fname);
|
||||||
void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
|
void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
|
||||||
unsigned char * extract (std::string srcfile, int & size); //return selecte file
|
unsigned char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
|
||||||
void extract(int index, std::string dstfile); //saves selected file
|
void extract(int index, std::string dstfile); //saves selected file
|
||||||
MemberFile getFile(std::string name);//nie testowane - sprawdzic
|
MemberFile getFile(std::string name);//nie testowane - sprawdzic
|
||||||
unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
|
unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user