mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +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->volume = 30;
|
||||
|
||||
this->sndPlayer = new CSndPlayer();
|
||||
}
|
||||
|
||||
void CMusicHandler::playClick()
|
||||
@ -65,4 +67,9 @@ void CMusicHandler::playClick()
|
||||
{
|
||||
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
|
||||
|
||||
#include "SDL_mixer.h"
|
||||
#include "CSndPlayer.h"
|
||||
|
||||
class CMusicHandler
|
||||
{
|
||||
protected:
|
||||
CSndPlayer *sndPlayer;
|
||||
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_Chunk * buildTown, *click;
|
||||
void initMusics();
|
||||
void playClick(); //plays click music ;]
|
||||
bool playLodSnd(std::string sndname); // plays sound wavs from Heroes3.snd
|
||||
};
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
CSndHandler::~CSndHandler()
|
||||
{
|
||||
entries.clear();
|
||||
fimap.clear();
|
||||
file.close();
|
||||
}
|
||||
CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
||||
@ -36,6 +37,7 @@ CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
|
||||
entry.offset = readNormalNr(-1,4);
|
||||
entry.size = readNormalNr(-1,4);
|
||||
entries.push_back(entry);
|
||||
fimap[entry.name] = i;
|
||||
}
|
||||
}
|
||||
int CSndHandler::readNormalNr (int pos, int bytCon)
|
||||
@ -124,6 +126,19 @@ unsigned char * CSndHandler::extract (int index, int & size)
|
||||
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()
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
struct MemberFile
|
||||
{
|
||||
std::ifstream * ifs;
|
||||
@ -22,10 +23,11 @@ protected:
|
||||
bool opened;
|
||||
public:
|
||||
std::vector<Entry> entries;
|
||||
std::map<std::string, int> fimap; // map of wav file and index
|
||||
~CSndHandler();
|
||||
CSndHandler(std::string fname);
|
||||
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
|
||||
MemberFile getFile(std::string name);//nie testowane - sprawdzic
|
||||
unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
|
||||
|
Loading…
x
Reference in New Issue
Block a user