ManaPlus
Static Public Member Functions
ItemSoundManager Class Reference

#include <itemsoundmanager.h>

Static Public Member Functions

static void playSfx (const int item, const ItemSoundEvent::Type sound)
 
static void playSfx (const Item *const item, const ItemSoundEvent::Type sound)
 
static void playSfx (const FloorItem *const item, const ItemSoundEvent::Type sound)
 
static void playSfx (const ItemInfo &info, const ItemSoundEvent::Type sound)
 
static void playSfx (const Being *const being, const int itemId, const ItemSoundEvent::Type sound)
 
static std::string getSoundEffect (const Being *const being, const ItemInfo &info, const ItemSoundEvent::Type sound)
 

Detailed Description

Definition at line 36 of file itemsoundmanager.h.

Member Function Documentation

◆ getSoundEffect()

std::string ItemSoundManager::getSoundEffect ( const Being *const  being,
const ItemInfo info,
const ItemSoundEvent::Type  sound 
)
static

Definition at line 57 of file itemsoundmanager.cpp.

60 {
61  std::string sfx = info.getSound(sound).sound;
62  if (sfx.empty())
63  {
64  if (being == nullptr)
65  return std::string();
66 
67  // fallback to player race sound if no item sound.
68  const int id = -100 - toInt(being->getSubType(), int);
69  const ItemInfo &info2 = ItemDB::get(id);
70  sfx = info2.getSound(sound).sound;
71  }
72  return sfx;
73 }
BeingTypeId getSubType() const
Definition: being.h:400
const SoundInfo & getSound(const ItemSoundEvent::Type event) const
Definition: iteminfo.cpp:161
#define toInt(val, name)
Definition: intdefines.h:47
bool info(InputEvent &event)
Definition: commands.cpp:57
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792
std::string sound
Definition: soundinfo.h:45

References ItemDB::get(), ItemInfo::getSound(), Being::getSubType(), Actions::info(), SoundInfo::sound, and toInt.

Referenced by playSfx().

◆ playSfx() [1/5]

void ItemSoundManager::playSfx ( const Being *const  being,
const int  itemId,
const ItemSoundEvent::Type  sound 
)
static

Definition at line 83 of file itemsoundmanager.cpp.

86 {
87  if (being == nullptr)
88  return;
89 
90  soundManager.playSfx(getSoundEffect(being, ItemDB::get(itemId), sound),
91  being->getTileX(),
92  being->getTileY());
93 }
int getTileX() const
Definition: being.h:168
int getTileY() const
Definition: being.h:174
static std::string getSoundEffect(const Being *const being, const ItemInfo &info, const ItemSoundEvent::Type sound)
void playSfx(const std::string &path, const int x, const int y) const
SoundManager soundManager

References ItemDB::get(), getSoundEffect(), Being::getTileX(), Being::getTileY(), SoundManager::playSfx(), and soundManager.

◆ playSfx() [2/5]

void ItemSoundManager::playSfx ( const FloorItem *const  item,
const ItemSoundEvent::Type  sound 
)
static

Definition at line 49 of file itemsoundmanager.cpp.

51 {
52  if (item == nullptr)
53  return;
54  playSfx(ItemDB::get(item->getItemId()), sound);
55 }
int getItemId() const
Definition: flooritem.h:82
static void playSfx(const int item, const ItemSoundEvent::Type sound)

References ItemDB::get(), FloorItem::getItemId(), and playSfx().

◆ playSfx() [3/5]

void ItemSoundManager::playSfx ( const int  item,
const ItemSoundEvent::Type  sound 
)
static

◆ playSfx() [4/5]

void ItemSoundManager::playSfx ( const Item *const  item,
const ItemSoundEvent::Type  sound 
)
static

Definition at line 35 of file itemsoundmanager.cpp.

37 {
38  if (item == nullptr)
39  return;
40  playSfx(item->getId(), sound);
41 }
int getId() const
Definition: item.h:81

References Item::getId(), and playSfx().

◆ playSfx() [5/5]

void ItemSoundManager::playSfx ( const ItemInfo info,
const ItemSoundEvent::Type  sound 
)
static

Definition at line 75 of file itemsoundmanager.cpp.

77 {
79  0,
80  0);
81 }
LocalPlayer * localPlayer

References getSoundEffect(), Actions::info(), localPlayer, SoundManager::playSfx(), and soundManager.


The documentation for this class was generated from the following files: