Browse Source

Fixed sound on object pickup with dialog

rhn 11 years ago
parent
commit
e9534603c2

+ 4 - 0
client/CPlayerInterface.cpp

@@ -22,6 +22,7 @@
 #include "../lib/Connection.h"
 #include "../lib/CSpellHandler.h"
 #include "../lib/CTownHandler.h"
+#include "../lib/mapObjects/CObjectClassesHandler.h" // For displaying correct UI when interacting with objects
 #include "../lib/BattleState.h"
 #include "../lib/JsonNode.h"
 #include "CMusicHandler.h"
@@ -1519,6 +1520,9 @@ void CPlayerInterface::objectRemoved( const CGObjectInstance *obj )
 	{
 		const CGHeroInstance *h = static_cast<const CGHeroInstance*>(obj);
 		heroKilled(h);
+	} else if (VLC->objtypeh->getObjectHandlerName(obj->ID) == "pickable") {
+		waitWhileDialog();
+		CCS->soundh->playSoundFromSet(CCS->soundh->pickupSounds);
 	}
 }
 

+ 5 - 0
lib/mapObjects/CObjectClassesHandler.cpp

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

+ 3 - 0
lib/mapObjects/CObjectClassesHandler.h

@@ -221,6 +221,9 @@ public:
 
 	std::string getObjectName(si32 type) 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)
 	{