mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
parent
d625066449
commit
ade4b46edd
@ -1,5 +1,7 @@
|
||||
#include "../../AI_Base.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../../hch/CSoundBase.h"
|
||||
|
||||
class CEmptyAI : public CGlobalAI
|
||||
{
|
||||
ICallback * cb;
|
||||
@ -13,7 +15,7 @@ public:
|
||||
void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
|
||||
void tileRevealed(int3 pos){};
|
||||
void tileHidden(int3 pos){};
|
||||
void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel){};
|
||||
void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, soundBase::soundNames soundID, bool selection, bool cancel){};
|
||||
void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, boost::function<void()> &onEnd){};
|
||||
void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ void GeniusAI::CGeniusAI::showGarrisonDialog( const CArmedInstance *up, const CG
|
||||
onEnd();
|
||||
}
|
||||
|
||||
void CGeniusAI::showBlockingDialog( const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel )
|
||||
void CGeniusAI::showBlockingDialog( const std::string &text, const std::vector<Component> &components, ui32 askID, soundBase::soundNames soundID, bool selection, bool cancel )
|
||||
{
|
||||
m_cb->selectionMade(cancel ? 0 : 1, askID);
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public:
|
||||
virtual void heroMoved(const HeroMoveDetails &);
|
||||
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val) {};
|
||||
virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
|
||||
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel);
|
||||
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, soundBase::soundNames soundID, bool selection, bool cancel);
|
||||
virtual void tileRevealed(int3 pos){};
|
||||
virtual void tileHidden(int3 pos){};
|
||||
virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
|
||||
|
@ -271,12 +271,12 @@ void CHeroGSlot::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
std::string tmp = CGI->generaltexth->allTexts[18]; //You already have %d adventuring heroes under your command.
|
||||
boost::algorithm::replace_first(tmp,"%d",boost::lexical_cast<std::string>(LOCPLINT->cb->howManyHeroes(false)));
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<SComponent*>());
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
allow = false;
|
||||
}
|
||||
else if(!other->hero->army.slots.size()) //hero has no creatures - strange, but if we have appropriate error message...
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<SComponent*>()); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<SComponent*>(), soundBase::sound_todo); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
allow = false;
|
||||
}
|
||||
}
|
||||
@ -523,7 +523,7 @@ void CCastleInterface::buildingClicked(int building)
|
||||
{
|
||||
if(LOCPLINT->cb->getResourceAmount(6) < 500) //not enough gold to buy spellbook
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[213],std::vector<SComponent*>());
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[213],std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -563,7 +563,7 @@ void CCastleInterface::buildingClicked(int building)
|
||||
}
|
||||
case 15: //resource silo
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->description,std::vector<SComponent*>());
|
||||
LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->description,std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
break;
|
||||
}
|
||||
case 16: //blacksmith
|
||||
@ -573,7 +573,7 @@ void CCastleInterface::buildingClicked(int building)
|
||||
{
|
||||
std::string pom = CGI->generaltexth->allTexts[273];
|
||||
boost::algorithm::replace_first(pom,"%s",CGI->buildh->buildings[town->subID][16]->Name());
|
||||
LOCPLINT->showInfoDialog(pom,std::vector<SComponent*>());
|
||||
LOCPLINT->showInfoDialog(pom,std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
return;
|
||||
}
|
||||
int aid = town->town->warMachine;
|
||||
@ -1535,7 +1535,7 @@ void CMageGuildScreen::Scroll::clickLeft (tribool down)
|
||||
std::vector<SComponent*> comps(1,
|
||||
new CCustomImgComponent(SComponent::spell,spell->id,0,graphics->spellscr->ourImages[spell->id].bitmap,false)
|
||||
);
|
||||
LOCPLINT->showInfoDialog(spell->descriptions[0],comps);
|
||||
LOCPLINT->showInfoDialog(spell->descriptions[0],comps, soundBase::sound_todo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <vector>
|
||||
#include "lib/BattleAction.h"
|
||||
#include "client/FunctionList.h"
|
||||
#include "hch/CMusicHandler.h"
|
||||
|
||||
/*
|
||||
* CGameInterface.h, part of VCMI engine
|
||||
@ -79,10 +80,10 @@ public:
|
||||
virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town){};
|
||||
virtual void init(ICallback * CB){};
|
||||
virtual void receivedResource(int type, int val){};
|
||||
virtual void showInfoDialog(const std::string &text, const std::vector<Component*> &components){};
|
||||
virtual void showInfoDialog(const std::string &text, const std::vector<Component*> &components, soundBase::soundNames soundID){};
|
||||
//virtual void showSelDialog(const std::string &text, const std::vector<Component*> &components, ui32 askID){};
|
||||
//virtual void showYesNoDialog(const std::string &text, const std::vector<Component*> &components, ui32 askID){};
|
||||
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel) = 0; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
|
||||
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, const soundBase::soundNames soundID, bool selection, bool cancel) = 0; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
|
||||
virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, boost::function<void()> &onEnd) = 0; //all stacks operations between these objects become allowed, interface has to call onEnd when done
|
||||
virtual void tileHidden(const std::set<int3> &pos){};
|
||||
virtual void tileRevealed(const std::set<int3> &pos){};
|
||||
|
@ -855,7 +855,7 @@ void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if(!down && pressedL)
|
||||
{
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
}
|
||||
ClickableL::clickLeft(down);
|
||||
}
|
||||
@ -901,7 +901,7 @@ void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
|
||||
if((!down) && pressedL)
|
||||
{
|
||||
std::vector<SComponent*> comp(1, new SComponent(SComponent::Etype(baseType), type, bonus));
|
||||
LOCPLINT->showInfoDialog(text, comp);
|
||||
LOCPLINT->showInfoDialog(text, comp, soundBase::sound_todo);
|
||||
}
|
||||
ClickableL::clickLeft(down);
|
||||
}
|
||||
|
@ -1173,7 +1173,15 @@ void CPlayerInterface::yourTurn()
|
||||
graphics->heroWins.insert(std::pair<int,SDL_Surface*>(hh[i]->subID,pom));
|
||||
}
|
||||
|
||||
adventureInt->infoBar.newDay(cb->getDate(1));
|
||||
/* TODO: This isn't quite right. First day in game should play
|
||||
* NEWDAY. And we don't play NEWMONTH. */
|
||||
int day = cb->getDate(1);
|
||||
if (day != 1)
|
||||
CGI->mush->playSound(soundBase::newDay);
|
||||
else
|
||||
CGI->mush->playSound(soundBase::newWeek);
|
||||
|
||||
adventureInt->infoBar.newDay(day);
|
||||
|
||||
//select first hero if available.
|
||||
//TODO: check if hero is slept
|
||||
@ -2071,6 +2079,9 @@ void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, int pskill, std:
|
||||
while(showingDialog->data)
|
||||
showingDialog->cond.wait(un);
|
||||
}
|
||||
|
||||
CGI->mush->playSound(soundBase::heroNewLevel);
|
||||
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
CLevelWindow *lw = new CLevelWindow(hero,pskill,skills,callback);
|
||||
LOCPLINT->pushInt(lw);
|
||||
@ -2170,6 +2181,7 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, int buildingID,
|
||||
switch(what)
|
||||
{
|
||||
case 1:
|
||||
CGI->mush->playSound(soundBase::newBuilding);
|
||||
castleInt->addBuilding(buildingID);
|
||||
break;
|
||||
case 2:
|
||||
@ -2394,15 +2406,15 @@ void CPlayerInterface::showComp(SComponent comp)
|
||||
adventureInt->infoBar.showComp(&comp,4000);
|
||||
}
|
||||
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<Component*> &components)
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<Component*> &components, soundBase::soundNames soundID)
|
||||
{
|
||||
std::vector<SComponent*> intComps;
|
||||
for(int i=0;i<components.size();i++)
|
||||
intComps.push_back(new SComponent(*components[i]));
|
||||
showInfoDialog(text,intComps);
|
||||
showInfoDialog(text,intComps,soundID);
|
||||
}
|
||||
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<SComponent*> & components)
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<SComponent*> & components, soundBase::soundNames soundID)
|
||||
{
|
||||
{
|
||||
boost::unique_lock<boost::mutex> un(showingDialog->mx);
|
||||
@ -2421,6 +2433,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
|
||||
|
||||
if(makingTurn && listInt.size())
|
||||
{
|
||||
CGI->mush->playSound(soundID);
|
||||
showingDialog->set(true);
|
||||
pushInt(temp);
|
||||
}
|
||||
@ -2447,10 +2460,11 @@ void CPlayerInterface::showYesNoDialog(const std::string &text, const std::vecto
|
||||
LOCPLINT->pushInt(temp);
|
||||
}
|
||||
|
||||
void CPlayerInterface::showBlockingDialog( const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel )
|
||||
void CPlayerInterface::showBlockingDialog( const std::string &text, const std::vector<Component> &components, ui32 askID, soundBase::soundNames soundID, bool selection, bool cancel )
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
|
||||
CGI->mush->playSound(soundID);
|
||||
|
||||
if(!selection && cancel) //simple yes/no dialog
|
||||
{
|
||||
|
@ -592,10 +592,10 @@ public:
|
||||
void heroMovePointsChanged(const CGHeroInstance * hero);
|
||||
void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town);
|
||||
void receivedResource(int type, int val);
|
||||
void showInfoDialog(const std::string &text, const std::vector<Component*> &components);
|
||||
void showInfoDialog(const std::string &text, const std::vector<Component*> &components, soundBase::soundNames soundID);
|
||||
//void showSelDialog(const std::string &text, const std::vector<Component*> &components, ui32 askID);
|
||||
//void showYesNoDialog(const std::string &text, const std::vector<Component*> &components, ui32 askID);
|
||||
void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, bool selection, bool cancel); //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
|
||||
void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, soundBase::soundNames soundID, bool selection, bool cancel); //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
|
||||
void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, boost::function<void()> &onEnd);
|
||||
void tileHidden(const std::set<int3> &pos);
|
||||
void tileRevealed(const std::set<int3> &pos);
|
||||
@ -636,7 +636,7 @@ public:
|
||||
void handleMouseMotion(SDL_Event *sEvent);
|
||||
void init(ICallback * CB);
|
||||
int3 repairScreenPos(int3 pos); //returns position closest to pos we can center screen on
|
||||
void showInfoDialog(const std::string &text, const std::vector<SComponent*> & components);
|
||||
void showInfoDialog(const std::string &text, const std::vector<SComponent*> & components, soundBase::soundNames soundID);
|
||||
void showYesNoDialog(const std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
|
||||
bool moveHero(const CGHeroInstance *h, CPath path);
|
||||
|
||||
|
@ -1973,6 +1973,7 @@ void CPreGame::scenHandleEv(SDL_Event& sEvent)
|
||||
{
|
||||
if (isItIn(&btns[i]->pos,sEvent.motion.x,sEvent.motion.y))
|
||||
{
|
||||
mush->playSound(soundBase::button);
|
||||
btns[i]->press(true);
|
||||
ourScenSel->pressed=(Button*)btns[i];
|
||||
}
|
||||
@ -1981,6 +1982,7 @@ void CPreGame::scenHandleEv(SDL_Event& sEvent)
|
||||
&& (sEvent.button.x>55) && (sEvent.button.x<372))
|
||||
{
|
||||
int py = ((sEvent.button.y-121)/25)+ourScenSel->mapsel.slid->whereAreWe;
|
||||
mush->playSound(soundBase::button);
|
||||
ourScenSel->mapsel.select(ourScenSel->mapsel.whichWL(py));
|
||||
}
|
||||
|
||||
@ -2199,7 +2201,6 @@ StartInfo CPreGame::runLoop()
|
||||
}
|
||||
else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
||||
{
|
||||
mush->playClick();
|
||||
for (size_t i=0; i < btns.size(); ++i)
|
||||
{
|
||||
if (isItIn(&btns[i]->pos,sEvent.motion.x,sEvent.motion.y))
|
||||
@ -2235,6 +2236,8 @@ StartInfo CPreGame::runLoop()
|
||||
highlightButton(5,1);
|
||||
current->highlighted=5;
|
||||
}
|
||||
if (current->highlighted)
|
||||
mush->playSound(soundBase::button);
|
||||
}
|
||||
else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../map.h"
|
||||
#include "../hch/CSpellHandler.h"
|
||||
#include "../hch/CSoundBase.h"
|
||||
#include "../mapHandler.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
@ -265,7 +266,7 @@ void InfoWindow::applyCl( CClient *cl )
|
||||
std::string str = toString(text);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint[player]->showInfoDialog(str,comps);
|
||||
cl->playerint[player]->showInfoDialog(str,comps,(soundBase::soundNames)soundID);
|
||||
else
|
||||
tlog2 << "We received InfoWindow for not our player...\n";
|
||||
}
|
||||
@ -284,7 +285,7 @@ void BlockingDialog::applyCl( CClient *cl )
|
||||
{
|
||||
std::string str = toString(text);
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint[player]->showBlockingDialog(str,components,id,selection(),cancel());
|
||||
cl->playerint[player]->showBlockingDialog(str,components,id,(soundBase::soundNames)soundID,selection(),cancel());
|
||||
else
|
||||
tlog2 << "We received YesNoDialog for not our player...\n";
|
||||
}
|
||||
|
@ -1,4 +1,11 @@
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
#include <SDL_mixer.h>
|
||||
|
||||
#include "CSndHandler.h"
|
||||
#include "CMusicHandler.h"
|
||||
|
||||
/*
|
||||
@ -11,17 +18,25 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using namespace boost::assign;
|
||||
|
||||
void CMusicHandler::initMusics()
|
||||
{
|
||||
if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096)==-1)
|
||||
if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1)
|
||||
{
|
||||
printf("Mix_OpenAudio error: %s!!!\n", Mix_GetError());
|
||||
//exit(2);
|
||||
sndh = NULL;
|
||||
return;
|
||||
}
|
||||
atexit(Mix_CloseAudio);
|
||||
|
||||
// Map sound names
|
||||
#define VCMI_SOUND_NAME(x) ( soundBase::x,
|
||||
#define VCMI_SOUND_FILE(y) cachedSounds(#y, 0) )
|
||||
sounds = boost::assign::map_list_of
|
||||
VCMI_SOUND_LIST;
|
||||
#undef VCMI_SOUND_NAME
|
||||
#undef VCMI_SOUND_FILE
|
||||
|
||||
//AITheme0 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITheme0.mp3");
|
||||
//AITheme1 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITHEME1.mp3");
|
||||
//AITheme2 = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "AITHEME2.mp3");
|
||||
@ -65,46 +80,60 @@ void CMusicHandler::initMusics()
|
||||
//winBattle = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Win Battle.mp3");
|
||||
//winScenario = Mix_LoadMUS(DATA_DIR "MP3" PATHSEPARATOR "Win Scenario.mp3");
|
||||
|
||||
click = Mix_LoadWAV(DATA_DIR "MP3" PATHSEPARATOR "snd1.wav");
|
||||
if(!click)
|
||||
tlog1 << "Cannot open " DATA_DIR "MP3" PATHSEPARATOR "snd1.wav\n";
|
||||
else
|
||||
click->volume = 30;
|
||||
|
||||
this->sndh = new CSndHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "Heroes3.snd"));
|
||||
// Map sounds
|
||||
sndh = new CSndHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "Heroes3.snd"));
|
||||
}
|
||||
|
||||
void CMusicHandler::playClick()
|
||||
// Return an SDL chunk. Allocate if it is not cached yet.
|
||||
Mix_Chunk *CMusicHandler::GetSoundChunk(std::string srcName)
|
||||
{
|
||||
if(!sndh) return;
|
||||
int channel;
|
||||
channel = Mix_PlayChannel(-1, click, 0);
|
||||
if(channel == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to play WAV file: %s\n", Mix_GetError());
|
||||
}
|
||||
}
|
||||
|
||||
void CMusicHandler::playLodSnd(std::string sndname)
|
||||
{
|
||||
if(!sndh) return;
|
||||
int size;
|
||||
const unsigned char *data;
|
||||
const char *data = sndh->extract(srcName, size);
|
||||
SDL_RWops *ops;
|
||||
Mix_Chunk *chunk;
|
||||
int channel;
|
||||
|
||||
if ((data = reinterpret_cast<const unsigned char*>(sndh->extract(sndname, size))) == NULL)
|
||||
return;
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
ops = SDL_RWFromConstMem(data, size);
|
||||
chunk = Mix_LoadWAV_RW(ops, 1);
|
||||
chunk = Mix_LoadWAV_RW(ops, 1); // will free ops
|
||||
|
||||
channel = Mix_PlayChannel(-1, chunk, 0);
|
||||
if (!chunk)
|
||||
fprintf(stderr, "Unable to mix: %s\n",
|
||||
Mix_GetError());
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// Plays a sound, and return its channel so we can fade it out later
|
||||
int CMusicHandler::playSound(soundBase::soundNames soundID)
|
||||
{
|
||||
int channel;
|
||||
|
||||
if (!sndh)
|
||||
return -1;
|
||||
|
||||
std::map<soundBase::soundNames, cachedSounds>::iterator it;
|
||||
|
||||
it = sounds.find(soundID);
|
||||
if (it == sounds.end())
|
||||
return -1;
|
||||
|
||||
class cachedSounds sound = it->second;
|
||||
|
||||
if (!sound.chunk) {
|
||||
sound.chunk = GetSoundChunk(sound.filename);
|
||||
}
|
||||
|
||||
if (sound.chunk)
|
||||
{
|
||||
channel = Mix_PlayChannel(-1, sound.chunk, 0);
|
||||
if(channel == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to play WAV file("DATA_DIR "Data" PATHSEPARATOR "Heroes3.wav::%s): %s\n",
|
||||
sndname.c_str(),Mix_GetError());
|
||||
sound.filename.c_str(),Mix_GetError());
|
||||
}
|
||||
ops->close(ops);
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
#ifndef __CMUSICHANDLER_H__
|
||||
#define __CMUSICHANDLER_H__
|
||||
|
||||
#include <SDL_mixer.h>
|
||||
#include "CSndHandler.h"
|
||||
#include "CSoundBase.h"
|
||||
|
||||
/*
|
||||
* CMusicHandler.h, part of VCMI engine
|
||||
@ -14,18 +13,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
struct Mix_Chunk;
|
||||
class CSndHandler;
|
||||
|
||||
class CMusicHandler
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
CSndHandler *sndh;
|
||||
|
||||
class cachedSounds {
|
||||
public:
|
||||
std::string filename;
|
||||
Mix_Chunk *chunk;
|
||||
|
||||
// This is some horrible C++ abuse. Isn't there any way to do
|
||||
// something simplier to init sounds?
|
||||
cachedSounds(std::string filename_in, Mix_Chunk *chunk_in):
|
||||
filename(filename_in), chunk(chunk_in) {};
|
||||
};
|
||||
|
||||
std::map<soundBase::soundNames, cachedSounds> sounds;
|
||||
|
||||
Mix_Chunk *GetSoundChunk(std::string srcName);
|
||||
|
||||
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;
|
||||
CMusicHandler(): sndh(NULL) {};
|
||||
void initMusics();
|
||||
void playClick(); //plays click music ;]
|
||||
void playLodSnd(std::string sndname); // plays sound wavs from Heroes3.snd
|
||||
|
||||
// Sounds
|
||||
int playSound(soundBase::soundNames soundID); // plays sound wavs from Heroes3.snd
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // __CMUSICHANDLER_H__
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include "CTownHandler.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "CSoundBase.h"
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include "../lib/IGameCallback.h"
|
||||
#include "../CGameState.h"
|
||||
@ -1092,6 +1093,7 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
|
||||
iw.components.push_back(Component(id,subid,val,0));
|
||||
iw.player = cb->getOwner(heroID);
|
||||
iw.text << std::pair<ui8,ui32>(11,ot);
|
||||
iw.soundID = soundBase::gazebo;
|
||||
cb->showInfoDialog(&iw);
|
||||
cb->changePrimSkill(heroID,4,val);
|
||||
break;
|
||||
@ -1962,6 +1964,7 @@ void CGPickable::onHeroVisit( const CGHeroInstance * h ) const
|
||||
sd.text << std::pair<ui8,ui32>(11,146);
|
||||
sd.components.push_back(Component(2,6,val1,0));
|
||||
sd.components.push_back(Component(5,0,val2,0));
|
||||
sd.soundID = soundBase::chest;
|
||||
boost::function<void(ui32)> fun = boost::bind(&CGPickable::chosen,this,_1,h->id);
|
||||
cb->showBlockingDialog(&sd,fun);
|
||||
return;
|
||||
@ -2061,6 +2064,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
case 14: //swan pond
|
||||
messageID = 29;
|
||||
iw.soundID = soundBase::faerie;
|
||||
gbonus.bonus.type = HeroBonus::LUCK;
|
||||
gbonus.bonus.val = 2;
|
||||
gbonus.bdescr << std::pair<ui8,ui32>(6,67);
|
||||
@ -2104,6 +2108,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
|
||||
break;
|
||||
case 96: //temple
|
||||
messageID = 140;
|
||||
iw.soundID = soundBase::temple;
|
||||
gbonus.bonus.type = HeroBonus::MORALE;
|
||||
if(cb->getDate(1)==7) //sunday
|
||||
{
|
||||
|
2076
hch/CSoundBase.h
Normal file
2076
hch/CSoundBase.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -526,12 +526,16 @@ struct InfoWindow : public CPackForClient //103 - displays simple info window
|
||||
MetaString text;
|
||||
std::vector<Component> components;
|
||||
ui8 player;
|
||||
ui16 soundID;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & text & components & player;
|
||||
h & text & components & player & soundID;
|
||||
}
|
||||
InfoWindow(){type = 103;};
|
||||
InfoWindow() {
|
||||
type = 103;
|
||||
soundID = 0;
|
||||
};
|
||||
};
|
||||
|
||||
struct SetObjectProperty : public CPackForClient//1001
|
||||
@ -594,6 +598,7 @@ struct BlockingDialog : public Query//2003
|
||||
std::vector<Component> components;
|
||||
ui8 player;
|
||||
ui8 flags;
|
||||
ui16 soundID;
|
||||
|
||||
bool cancel() const
|
||||
{
|
||||
@ -608,6 +613,7 @@ struct BlockingDialog : public Query//2003
|
||||
{
|
||||
type = 2003;
|
||||
flags = 0;
|
||||
soundID = 0;
|
||||
if(yesno) flags |= ALLOW_CANCEL;
|
||||
if(Selection) flags |= SELECTION;
|
||||
}
|
||||
@ -615,11 +621,12 @@ struct BlockingDialog : public Query//2003
|
||||
{
|
||||
type = 2003;
|
||||
flags = 0;
|
||||
soundID = 0;
|
||||
};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & id & text & components & player & flags;
|
||||
h & id & text & components & player & flags & soundID;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -396,6 +396,10 @@
|
||||
RelativePath=".\Connection.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\hch\CSoundBase.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\hch\CSpellHandler.h"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user