1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Merge pull request #35 from rhn/rhn

Fixes to sound handling.
This commit is contained in:
Ivan Savenko 2014-09-04 20:26:32 +03:00
commit 1647b3670c
6 changed files with 41 additions and 14 deletions

View File

@ -31,43 +31,50 @@ On Debian-based systems (e.g. Ubuntu) run:
sudo apt-get install cmake g++ libsdl1.2debian libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev qtbase5-dev sudo apt-get install cmake g++ libsdl1.2debian libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev zlib1g-dev libavformat-dev libswscale-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-locale-dev qtbase5-dev
On RPM-based distributions (e.g. Fedora) run: On RPM-based distributions (e.g. Fedora) run:
sudo yum install cmake gcc-c++ SDL-devel SDL_image-devel SDL_ttf-devel SDL_mixer-devel boost boost-devel boost-filesystem boost-system boost-thread boost-program-options boost-locale zlib-devel ffmpeg-devel ffmpeg-libs sudo yum install cmake gcc-c++ SDL2-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel boost boost-devel boost-filesystem boost-system boost-thread boost-program-options boost-locale zlib-devel ffmpeg-devel ffmpeg-libs
II. Getting the sources II. Getting the sources
VCMI is still in development. We recommend the following initial directory structure: VCMI is still in development. We recommend the following initial directory structure:
trunk trunk
trunk/src -> contains sources and is under SVN control trunk/vcmi -> contains sources and is under git control
trunk/build -> contains build output, makefiles, object files,... trunk/build -> contains build output, makefiles, object files,...
You can get latest sources with subversion: You can get latest sources with subversion:
cd trunk git clone https://github.com/vcmi/vcmi.git
svn co http://svn.code.sf.net/p/vcmi/code/trunk/
III. Compilation III. Compilation
Run configure: Run configure:
mkdir build && cd build mkdir build && cd build
cmake ../src <any other options, see below> cmake ../vcmi <any other options, see below>
Additional options that you may want to use: Additional options that you may want to use:
To enable debugging: -DCMAKE_BUILD_TYPE=Debug To enable debugging: -DCMAKE_BUILD_TYPE=Debug
To enable launcher: -DENABLE_LAUNCHER=Yes To change installation directory: -DCMAKE_INSTALL_PREFIX=$absolute_path_to_directory
Notice: Notice:
The ../src/ is not a typo, it will place makefile scripts into the build dir The ../vcmi/ is not a typo, it will place makefile scripts into the build dir
as the build dir is your working dir when calling CMake. as the build dir is your working dir when calling CMake.
Then build vcmi: Then build vcmi:
make -j2 (j2 = compile with 2 cpu cores, you can specifiy any value) make -j2 (j2 = compile with 2 threads, you can specify any value)
That will generate vcmiclient, vcmiserver as well as 3 .so libraries. That will generate vcmiclient, vcmiserver, vcmilauncher as well as 3 .so libraries.
III. Installing binaries III. Installing binaries
To install VCMI you can use "make install" command however generation of distribution-specific packages is usually a better idea. In most cases this can be achieved using tool called "checkinstall" To install VCMI you can use "make install" command however generation of distribution-specific packages is usually a better idea. In most cases this can be achieved using tool called "checkinstall"
If you're compiling vcmi for development puposes, it's better to use links instead. If you're compiling vcmi for development puposes, the easiest is to use cmake prefix and then make install:
# mkdir .../trunk/install
# cmake -DCMAKE_INSTALL_PREFIX=.../trunk/install ../vcmi
# make && make install
# .../trunk/install/bin/vcmiclient
it's better to use links instead.
Go to /BIN_PATH/, and type: Go to /BIN_PATH/, and type:
ln -s .../trunk/build/client/vcmiclient ln -s .../trunk/build/client/vcmiclient
@ -86,5 +93,3 @@ Go to /LIB_PATH/vcmi/AI, and type:
Go to /DATA_PATH/vcmi, and type: Go to /DATA_PATH/vcmi, and type:
ln -s .../trunk/source/config ln -s .../trunk/source/config
ln -s .../trunk/source/Mods ln -s .../trunk/source/Mods

View File

@ -22,6 +22,7 @@
#include "../lib/Connection.h" #include "../lib/Connection.h"
#include "../lib/CSpellHandler.h" #include "../lib/CSpellHandler.h"
#include "../lib/CTownHandler.h" #include "../lib/CTownHandler.h"
#include "../lib/mapObjects/CObjectClassesHandler.h" // For displaying correct UI when interacting with objects
#include "../lib/BattleState.h" #include "../lib/BattleState.h"
#include "../lib/JsonNode.h" #include "../lib/JsonNode.h"
#include "CMusicHandler.h" #include "CMusicHandler.h"
@ -1515,6 +1516,16 @@ void CPlayerInterface::centerView (int3 pos, int focusTime)
void CPlayerInterface::objectRemoved( const CGObjectInstance *obj ) void CPlayerInterface::objectRemoved( const CGObjectInstance *obj )
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
if (LOCPLINT->cb->getCurrentPlayer() == playerID) {
std::string handlerName = VLC->objtypeh->getObjectHandlerName(obj->ID);
if ((handlerName == "pickable") || (handlerName == "scholar") || (handlerName== "artifact") || (handlerName == "pandora")) {
waitWhileDialog();
CCS->soundh->playSoundFromSet(CCS->soundh->pickupSounds);
} else if ((handlerName == "monster") || (handlerName == "hero")) {
waitWhileDialog();
CCS->soundh->playSound(soundBase::KillFade);
}
}
if(obj->ID == Obj::HERO && obj->tempOwner == playerID) if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
{ {
const CGHeroInstance *h = static_cast<const CGHeroInstance*>(obj); const CGHeroInstance *h = static_cast<const CGHeroInstance*>(obj);

View File

@ -3,6 +3,9 @@
// Use some magic to keep the list of files and their code name in sync. // Use some magic to keep the list of files and their code name in sync.
#define VCMI_SOUND_LIST \ #define VCMI_SOUND_LIST \
/* Sounds for map actions */ \
VCMI_SOUND_NAME(KillFade) VCMI_SOUND_FILE(KILLFADE.wav) /* hero or monster disappears */ \
/* Other sounds (TODO: separate out the sounds for units, spells and the rest */ \
VCMI_SOUND_NAME(AAGLAttack) VCMI_SOUND_FILE(AAGLATTK.wav) \ VCMI_SOUND_NAME(AAGLAttack) VCMI_SOUND_FILE(AAGLATTK.wav) \
VCMI_SOUND_NAME(AAGLDefend) VCMI_SOUND_FILE(AAGLDFND.wav) \ VCMI_SOUND_NAME(AAGLDefend) VCMI_SOUND_FILE(AAGLDFND.wav) \
VCMI_SOUND_NAME(AAGLKill) VCMI_SOUND_FILE(AAGLKILL.wav) \ VCMI_SOUND_NAME(AAGLKill) VCMI_SOUND_FILE(AAGLKILL.wav) \
@ -515,7 +518,6 @@ VCMI_SOUND_NAME(ITRGKill) VCMI_SOUND_FILE(ITRGKILL.wav) \
VCMI_SOUND_NAME(ITRGMove) VCMI_SOUND_FILE(ITRGMOVE.wav) \ VCMI_SOUND_NAME(ITRGMove) VCMI_SOUND_FILE(ITRGMOVE.wav) \
VCMI_SOUND_NAME(ITRGWNCE) VCMI_SOUND_FILE(ITRGWNCE.wav) \ VCMI_SOUND_NAME(ITRGWNCE) VCMI_SOUND_FILE(ITRGWNCE.wav) \
VCMI_SOUND_NAME(KEEPShot) VCMI_SOUND_FILE(KEEPSHOT.wav) \ VCMI_SOUND_NAME(KEEPShot) VCMI_SOUND_FILE(KEEPSHOT.wav) \
VCMI_SOUND_NAME(KillFADE) VCMI_SOUND_FILE(KILLFADE.wav) \
VCMI_SOUND_NAME(LANDKill) VCMI_SOUND_FILE(LANDKILL.wav) \ VCMI_SOUND_NAME(LANDKill) VCMI_SOUND_FILE(LANDKILL.wav) \
VCMI_SOUND_NAME(LANDMINE) VCMI_SOUND_FILE(LANDMINE.wav) \ VCMI_SOUND_NAME(LANDMINE) VCMI_SOUND_FILE(LANDMINE.wav) \
VCMI_SOUND_NAME(LCRSAttack) VCMI_SOUND_FILE(LCRSATTK.wav) \ VCMI_SOUND_NAME(LCRSAttack) VCMI_SOUND_FILE(LCRSATTK.wav) \
@ -1033,4 +1035,4 @@ public:
}; };
#undef VCMI_SOUND_NAME #undef VCMI_SOUND_NAME
#undef VCMI_SOUND_FILE #undef VCMI_SOUND_FILE
}; };

View File

@ -110,6 +110,7 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
(".AVI", EResType::VIDEO) (".AVI", EResType::VIDEO)
(".MP3", EResType::MUSIC) (".MP3", EResType::MUSIC)
(".OGG", EResType::MUSIC) (".OGG", EResType::MUSIC)
(".FLAC", EResType::MUSIC)
(".ZIP", EResType::ARCHIVE_ZIP) (".ZIP", EResType::ARCHIVE_ZIP)
(".LOD", EResType::ARCHIVE_LOD) (".LOD", EResType::ARCHIVE_LOD)
(".PAC", EResType::ARCHIVE_LOD) (".PAC", EResType::ARCHIVE_LOD)

View File

@ -318,6 +318,11 @@ std::string CObjectClassesHandler::getObjectName(si32 type, si32 subtype) const
return getObjectName(type); return getObjectName(type);
} }
std::string CObjectClassesHandler::getObjectHandlerName(si32 type) const
{
return objects.at(type)->handlerName;
}
void AObjectTypeHandler::setType(si32 type, si32 subtype) void AObjectTypeHandler::setType(si32 type, si32 subtype)
{ {
this->type = type; this->type = type;

View File

@ -221,6 +221,9 @@ public:
std::string getObjectName(si32 type) const; std::string getObjectName(si32 type) const;
std::string getObjectName(si32 type, si32 subtype) const; std::string getObjectName(si32 type, si32 subtype) const;
/// Returns handler string describing the handler (for use in client)
std::string getObjectHandlerName(si32 type) const;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {